//
//  BuyTicketViewController.m
//  Mtime2.0
//
//  Created by 凉气的Mac on 16/9/3.
//  Copyright © 2016年 凉气的Mac. All rights reserved.
//

#import "BuyTicketViewController.h"

#import "MoveView.h"

#import "CinemaView.h"

#import "MtimeButton.h"

@interface BuyTicketViewController ()

@property(nonatomic,weak) CinemaView *cinema;

@property(nonatomic,weak) MoveView *movie;



@end

@implementation BuyTicketViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.view.backgroundColor = [UIColor whiteColor];
    
    [self setupNavigationBar];
    
}


-(void)setupNavigationBar{

    [self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@"menu_top_bg7"] forBarMetrics:UIBarMetricsDefault];
    
    self.navigationController.navigationBar.tintColor = [UIColor whiteColor];

    MtimeButton *leftBtn = [[MtimeButton alloc]initWithFrame:CGRectMake(0, 0, 50, 30)];
    
    [leftBtn setTitle:@"上海" forState:UIControlStateNormal];
    
    [leftBtn setImage:[UIImage imageNamed:@"homepage_selectcity"] forState:UIControlStateNormal];
    
    UIBarButtonItem *leftItem = [[UIBarButtonItem alloc]initWithCustomView:leftBtn];
    
    self.navigationItem.leftBarButtonItem = leftItem;
    
    UIBarButtonItem *rightItem = [[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemSearch target:nil action:nil];
    
    self.navigationItem.rightBarButtonItem = rightItem;
    
    //设置segment
    UISegmentedControl *segment = [[UISegmentedControl alloc]initWithItems:@[@"电影",@"影院"]];
    
    [segment.layer setBorderWidth:0.5];
    
    segment.layer.cornerRadius = 15;
    
    segment.clipsToBounds = YES;
    
    [segment setWidth:70 forSegmentAtIndex:0];
    [segment setWidth:70 forSegmentAtIndex:1];
    
    self.navigationItem.titleView = segment;
    
    segment.userInteractionEnabled = YES;
    
    [segment addTarget:self action:@selector(clickSegment:) forControlEvents:UIControlEventValueChanged];
    
    segment.selectedSegmentIndex = 0;
    
    [self clickSegment:segment];
    
  
    MoveView *movie = [[MoveView alloc]init];
    
    self.movie = movie;
    
    [self.view addSubview:movie];
    
    [movie mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.edges.equalTo(self.view);
        
    }];
    

    CinemaView *cinema = [[CinemaView alloc]init];
    
    self.cinema = cinema;
    
    [self.view addSubview:cinema];
    
    [cinema mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.edges.equalTo(self.view);
        
    }];


    
    
    
}




-(void)clickSegment:(UISegmentedControl *)segment{
    

    if (segment.selectedSegmentIndex == 0) {
        
        self.movie.hidden = NO;
        
        self.cinema.hidden = YES;
        
    }else{
        
        self.movie.hidden = YES;
        
        self.cinema.hidden = NO;
        
    }
    
}



@end
























































